#include<bits/stdc++.h>
using namespace std;
int n,a[500010],used[500010],t,k;
bool flag;
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	int i=1;
	while (a[i]==-1&&i<=n)
				i++;
		flag=a[i];
	a[n+1]=a[n];
	while (t<n)
	{
		k=0;
		int i=1;
		while (a[i]==-1&&i<=n)
				i++;
		flag=a[i];
		for (int i=1;i<=n;i++)
		{
			while (a[i]==-1||flag!=a[i]&&i<=n)
				i++;
			flag=!flag;
			if (i<=n)
			{
				t++;
				cout<<i<<" ";
			}
			a[i]=-1;
			while (a[i+1]==a[i]&&i<=n)
				i++;
		}
		cout<<'\n';
	}
	return 0;
 } 
 /* 
20
1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 0 0 0 
 */
